import 'package:flutter/material.dart';

/**
 * 用来定义中所使用到的颜色主题
 */
class ThemeConfigModel with ChangeNotifier {
  // 亮色主题色 应用程序默认的主题色
  final ThemeData lightTheme = new ThemeData(
    // 亮色
    brightness: Brightness.light,
    // 主背景色
    primaryColor: Colors.white,
    buttonTheme: ButtonThemeData(
      buttonColor: Colors.blue,
      highlightColor: Colors.blue[700],
    ),
  );

  final ThemeData darkTheme = ThemeData(
    // 亮色
    brightness: Brightness.dark,
    // 主背景色
    primaryColor: Colors.grey,
    buttonTheme: ButtonThemeData(
      buttonColor: Colors.grey[700],
      highlightColor: Colors.blue[800],
    ),
  );

  ThemeData defaultTheme;
  void setTheme(num index) {
    switch (index) {
      case 0:
        defaultTheme = lightTheme;
        break;
      case 1:
        defaultTheme = darkTheme;
        break;
      default:
        defaultTheme = lightTheme;
        break;
    }
    // 使用 notifyListeners() 函数 通知监听者已更新界面的数据
    notifyListeners();
  }
}
